package com.wyd.qxglht.model;

import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.validator.constraints.Length;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import lombok.Data;
@Data
@Entity
@Table
@EntityListeners(AuditingEntityListener.class)
@GenericGenerator(name = "jpa-uuid",strategy = "uuid")
public class Users {

    @Id
    @GeneratedValue(generator = "jpa-uuid")
    @Column(length = 32)
    private String id; //编号
    @Column(unique = true , nullable = false)
    private String loginName; //登录名
    @NotNull
    @Length(min = 6 , max = 20)
    private String password; //密码 ,不能为空，6~20位字符
    @Column(name = "is_locked" ,length = 10,columnDefinition = "char(2) default '否'",insertable = false)
    private String isLockout; //是否锁定,默认 否
    @LastModifiedDate //最后修改时间
    private Date lastLoginTime; //最后一次登录时间
    @CreatedDate //
    @Column(updatable = false , nullable = false)
    private Date creatTime; //帐户创立时间
    @Column(name ="psd_wrong_time", columnDefinition = "int default 0")
    private Integer psdWrongTime; //密码错误次数
    private Date lockTime; //被锁定时间
    @Email
    private String protectEMail; //密保邮箱,邮箱格式验证
    @Pattern(regexp = "^[1]([3-9])[0-9]{9}$")
    private String protectMTel; //密保手机号


    //用户相关角色
  //  @ManyToMany(cascade = CascadeType.REFRESH)
    
   // private List<Roles> rolesList;//角色id
}